Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

barcode-detector

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

barcode-detector

Spec compliant polyfill of the [Barcode Detection API](https://wicg.github.io/shape-detection-api/#barcode-detection-api). It can be used for barcode/QR-code recognition in images from various kinds of sources including `<canvas>`, ``, `` (in

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38K
decreased by-11.29%
Maintainers
1
Weekly downloads
 
Created
Source

:construction: WIP: BarcodeDetector Polyfill :construction:

Spec compliant polyfill of the Barcode Detection API. It can be used for barcode/QR-code recognition in images from various kinds of sources including <canvas>, <img>, <image> (inside SVGs), <video>, File, Blob, ImageData, ImageBitmap, OffscreenCanvas.

simple demo

Design goals:

  • spec compliance
  • support as many barcode formats as possible
  • detect multiple codes in one image
  • provide position/coordinate information of detected codes
  • sufficient performance to process live video streams

Installation

npm install barcode-detector
import BarcodeDetector from "barcode-detector"

// polyfill unless already supported
if (!("BarcodeDetector" in window)) {
  window.BarcodeDetector = BarcodeDetector
}

Usage

// pick barcode formats. Other formats will be ignored
const barcodeDetector = new BarcodeDetector({ formats: ["qr_code"] })

// directly pass an image element, video element, ...
const barcodes = await barcodeDetector.detect(someImageSource)

// can detect multiple barcodes in one image
const [ barcode1, barcode2, ...evenMoreBarcodes ] = barcodes

// access encoded string
const { rawValue } = barcode1

For in-depth documentation checkout the corresponding MDN page.

Supported Formats

src/BarcodeDetectorJsqr.ts:

  • :x: aztec
  • :x: code_128
  • :x: code_39
  • :x: code_93
  • :x: codabar
  • :x: data_matrix
  • :x: ean_13
  • :x: ean_8
  • :x: itf
  • :x: pdf417
  • :heavy_check_mark: qr_code
  • :x: upc_a
  • :x: upc_e

src/BarcodeDetectorZXing.ts (not exposed at the moment. See #1):

  • :heavy_check_mark: aztec
  • :heavy_check_mark: code_128
  • :heavy_check_mark: code_39
  • :x: code_93
  • :x: codabar
  • :heavy_check_mark: data_matrix
  • :heavy_check_mark: ean_13
  • :heavy_check_mark: ean_8
  • :heavy_check_mark: itf
  • :heavy_check_mark: pdf417
  • :heavy_check_mark: qr_code
  • :x: upc_a
  • :x: upc_e

FAQs

Package last updated on 02 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc